from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from rest_framework.routers import DefaultRouter
from .views import statistical, users, specs,images,skus,orders,permissions,groups

urlpatterns = [
    # JWT 登录
    url(r'^authorizations/$', obtain_jwt_token),
    # ---------数据统计------------
    # 用户总数统计
    url(r'^statistical/total_count/$', statistical.UserTotalCountView.as_view()),
    # 当天注册用户总数统计
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    # 当天登录用户总数统计
    url(r'^statistical/day_active/$', statistical.UserDayCountActiveView.as_view()),
    # 当天下单用户总数统计
    url(r'^statistical/day_orders/$', statistical.UserDayCountOrdersView.as_view()),
    # 一个月范围的注册用户总数统计
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    url(r'^statistical/goods_day_views/$', statistical.GoodsTypeCountView.as_view()),
    # ----------用户数据操作------------
    url(r'^users/$', users.UserView.as_view()),
    # ------- 规格表路由匹配-----------
    # 获取spu商品
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get':'simple'})),

    # ------- 图片表路由匹配-----------
    # 获取sku商品
    url(r'^skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # 获取权限分类
    url(r'^permission/content_types/$', permissions.PermissionView.as_view({'get': 'content_types'})),
    # 获取分组中的所有权限
    url(r'^permission/simple/$', groups.GroupView.as_view({'get': 'simple'})),
]
# ------- 规格表路由匹配-----------
# goods/specs/simple
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='spec')
urlpatterns += router.urls


# ------- 图片表路由匹配-----------
# skus/images/simple
router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='image')
urlpatterns += router.urls
# ------- SKU表路由匹配-----------
router = DefaultRouter()
# skus/categories/
router.register('skus', skus.SKUView, base_name='skus')
urlpatterns += router.urls

# ------- 订单表路由匹配-----------
router = DefaultRouter()
router.register('orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

# ------- 权限表路由匹配-----------
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionView, base_name='perms')
urlpatterns += router.urls

# ------- 分组表路由匹配-----------
router = DefaultRouter()
router.register('permission/groups', groups.GroupView, base_name='groups')
urlpatterns += router.urls